package cn.com.b2office.struts2.action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import cn.com.b2office.domain.Cart;
import cn.com.b2office.service.CartService;

import com.opensymphony.xwork2.ActionSupport;

public class RemoveCartItemAction extends ActionSupport implements SessionAware {

	private static final long serialVersionUID = 1337726402540098624L;

	private CartService cartService = null;

	private Map session = null;

	private int cartItemId = 0;

	public String execute() throws Exception {
		Cart cart = (Cart) session.get("cart");
		if (cart == null)
			return "empty";
		cartService.removeItemFromCart(cart, cartItemId);
		return SUCCESS;
	}

	public void setCartService(CartService cartService) {
		this.cartService = cartService;
	}

	public void setSession(Map session) {
		this.session = session;
	}

	public void setCartItemId(int cartItemId) {
		this.cartItemId = cartItemId;
	}

}
